<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath =request.getScheme()+"://"+request.getServerName()+":"
+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="<%=basePath%>">
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
<script src="bootstrap/js/jquery-1.12.4.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<title>提问</title>
<script type="text/javascript">
function baocun(){
	var obj = new Object();
	obj.title=$("#title").val();
	obj.tags=$("#tags").val();
	obj.desc=$("#desc").val();
	if(!obj.title.trim()){
		alert("标题不能为空");
		return false;
	}
	if(!obj.tags.trim()){
		alert("标签不能为空");
		return false;
	}
	if(!/[\w\W]{5,}/.test(obj.title)){
		alert("标题不能少于五个字");
		return false;
	}
	if(!/^[\w\W]{2,10}$/.test(obj.tags)){
		alert("标签必须是2至10位");
		return false;
	}
	$.post("<%=basePath%>QuestionController/insertQuestion",obj,function(result){
		 if (result.success) {
			 Dialog.alert("成功");
	     } else {
	    	 Dialog.alert(result.msg);
	     }
	     hideWaiting();
	}, 'json');
}

</script>
</head>
<body>
<div>
	<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  提问
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">问题</h4>
      </div>
      <div class="modal-body">
        	标题<br>
        	<input type="text" name="title" id="title"><span></span><br>
        	标签<br>
        	<input type="text" name="tags" id="tags"><br>
        	描述(可选)<br>
        	<input type="text" name="desc" id="desc"><br>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <input type="button" class="btn btn-primary" onclick="baocun()" value="提交"/>
      </div>
    </div>
  </div>
</div>
</div>
</body>
</html>